package com.yuxi.shuzu;

import java.util.Arrays;
import java.util.Scanner;

public class Demo9 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] arr = new int[6];
//        int[] arr = {1,2,3,4,5,6};
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个数");
            arr[i] = input.nextInt();
        }
        System.out.println(Arrays.toString(arr));
        for (int i = 0; i < arr.length/2; i++) {
            int temp = 0;
            temp = arr[i];
            arr[i] = arr[arr.length-1-i];
            arr[arr.length-1-i] = temp;
        }
        System.out.println("反转："+Arrays.toString(arr));
        for (int i = 0; i < arr.length; i++) {
            if (i%2!=0&&arr.length-i>1){
                int temp = 0;
                temp = arr[i];
                arr[i] = arr[i+2];
                arr[i+2] = temp;
            }
        }
        System.out.println("1-3 3-5："+Arrays.toString(arr));

        int f = 0,l = 0;
        for (int i = 0; i < arr.length; i++) {
            if (i%2!=0){
                f = i;
                break;
            }
        }
        for (int i = arr.length-1; i > 0 ; i--) {
            if (i%2!=0){
                l = i;
                break;
            }
        }
        int temp = 0;
        temp = arr[f];
        arr[f] = arr[l];
        arr[l] = temp;
        System.out.println("5-1："+Arrays.toString(arr));
        System.out.println("最终数组为："+Arrays.toString(arr));

    }
}
